<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Father(uname, age) {
            this.name = uname;
            this.age = age;
        };
        Father.prototype.Sing = function () {
            console.log("唱山歌");
        }

        function Son(n, a, sex) {
            Father.call(this, n, a) // 通过call方法,调用父级函数,继承属性 ,call可改变this指向,改变父级里面的this,让其指向子级
            this.sex = sex;
        }
        Son.prototype = new Father(); // 创建父级实例对象赋值给子构造函数的原型对象 继承方法
        Son.prototype.constructor = Son; // 赋值操作,覆盖了子构造函数的原型对象属性constructor,所以需要手动指向构造函数本身
        Son.prototype.Song = function () {
            console.log("山路十八弯");
        }
        var s = new Son("gfc", 50, "男");
        console.log(s);
        s.Sing();
        s.Song();
        console.log(Son.prototype.constructor);
        console.log(Father.prototype);
    </script>
</body>

</html>